﻿<UserControl x:Class="LiveTiss.Guias.UserControls.DiagnosticoSaidaInternacao"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:uc="clr-namespace:LiveTiss.Guias.UserControls"
    xmlns:converter="clr-namespace:LiveTiss.Classes.TypeConverter"
    mc:Ignorable="d" Width="910" x:Name="uc">

    <UserControl.Resources>
        <converter:EnumConverter x:Key="enumConverter"  />
        <converter:BoolToVisibilityConverter x:Key="visibilityConverter" />
    </UserControl.Resources>

    <StackPanel Width="910">
        <Grid Margin="0,19,0,0" VerticalAlignment="Top">
            <Rectangle RadiusY="6" RadiusX="6" Stroke="#4D898989"/>
            <TextBlock TextWrapping="Wrap" Text="Dados da Saída da Internação" Margin="10,10,8,0" VerticalAlignment="Top" FontFamily="Segoe UI Semibold" FontSize="16"/>
            <StackPanel Margin="12,44,8,0">
                <uc:CID Value="{Binding Path=Value.diagnosticoPrincipal, ElementName=uc, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" />
                <Grid Margin="0,0,6,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.024*"/>
                        <ColumnDefinition Width="0.976*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.ColumnSpan="2" Margin="0" Grid.Column="2">
                        <CheckBox Name="cbxDiag" Content="Diagnostico Secundario" FontFamily="Segoe UI" FontSize="13.333" />
                        <Button Name="btnAdd" Width="200" HorizontalAlignment="Left" Content="Adicionar Diagnostico" Click="btnAdd_Click" 
                            Visibility="{Binding Path=IsChecked,ElementName=cbxDiag,Converter={StaticResource visibilityConverter}}" />
                    </StackPanel>
                </Grid>
                <ItemsControl Name="diagnosticoSecundarioControl"
                    ItemsSource="{Binding Path=Value.diagnosticosSecundarios, ElementName=uc, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" 
                    Visibility="{Binding Path=IsChecked,ElementName=cbxDiag,Converter={StaticResource visibilityConverter}}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel x:Name="CIDPanel" Orientation="Vertical" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <ContentControl>
                                <StackPanel Orientation="Vertical" Loaded="StackPanel_Loaded">
                                    <uc:CID x:Name="CIDUserControl"/>
                                    <Button Name="btnDelete" Margin="50,0,0,0" Width="100" HorizontalAlignment="Left" Content="Remover" Click="btnDelete_Click"  />
                                </StackPanel>
                            </ContentControl>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <Grid Height="53" Margin="0,0,6,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.024*"/>
                        <ColumnDefinition Width="0.976*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.ColumnSpan="2" Margin="0" Grid.Row="2" Grid.Column="2">
                        <TextBlock TextWrapping="Wrap" Text="Motivo Saída:" FontFamily="Segoe UI" FontSize="13.333"/>
                        <ComboBox Width="300" Margin="0,6,0,0" HorizontalAlignment="Left" Height="25" SelectedValue="Key" DisplayMemberPath="Value"
                            ItemsSource="{Binding Path=Value.MotivoSaidaInternacaoItems, ElementName=uc, Mode=OneWay}"
                            SelectedIndex="{Binding Path=Value.motivoSaidaInternacao, ElementName=uc, Converter={StaticResource enumConverter}, ConverterParameter='MotivoSaida', ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}"
                            />
                    </StackPanel>
                    <TextBlock TextWrapping="Wrap" Text="*" FontFamily="Segoe UI" FontWeight="Bold" FontSize="21.333" Foreground="#FF307852" Height="16" VerticalAlignment="Top" Margin="0,0,3,0" d:LayoutOverrides="Width"/>
                </Grid>
                <Grid Margin="0,0,6,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.024*"/>
                        <ColumnDefinition Width="0.976*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.ColumnSpan="2" Margin="0" Grid.Column="2">
                        <CheckBox Name="cbxObito" Content="Óbito" FontFamily="Segoe UI" FontSize="13.333" />
                        <Button Name="btnAddObito" Width="200" HorizontalAlignment="Left" Content="Adicionar Óbito" Click="btnAddObito_Click" 
                            Visibility="{Binding Path=IsChecked,ElementName=cbxObito,Converter={StaticResource visibilityConverter}}" />
                    </StackPanel>
                </Grid>
                <ItemsControl Name="obitoControl" Margin="0,0,0,10"
                    ItemsSource="{Binding Path=Value.obito, ElementName=uc, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" 
                    Visibility="{Binding Path=IsChecked,ElementName=cbxObito,Converter={StaticResource visibilityConverter}}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <ContentControl>
                                <StackPanel Orientation="Vertical" Loaded="StackPanel_Loaded_1">
                                    <uc:ObitoInternacao x:Name="ucObitoInternacao"/>
                                    <Button Name="btnDeleteObito" Margin="50,0,0,0" Width="100" HorizontalAlignment="Left" Content="Remover" Click="btnDeleteObito_Click"  />
                                </StackPanel>
                            </ContentControl>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                
                <Grid Height="53" Margin="0,0,6,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0.024*"/>
                        <ColumnDefinition Width="0.976*"/>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.ColumnSpan="2" Margin="0" Grid.Row="2" Grid.Column="2">
                        <CheckBox Name="chkIndicacaoAcidente" Content="Indicador de Acidente" FontFamily="Segoe UI" FontSize="13.333"
                            IsChecked="{Binding Path=Value.indicadorAcidenteSpecified, ElementName=uc, ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}" />
                        <ComboBox Name="cbxIndicacaoAcidente" Width="280" Margin="0,6,0,0" SelectedValue="Key" DisplayMemberPath="Value" HorizontalAlignment="Left" 
                            ItemsSource="{Binding Path=Value.IndicadorAcidenteItems, ElementName=uc, Mode=OneWay}"
                            SelectedIndex="{Binding Path=Value.indicadorAcidente,ElementName=uc, Converter={StaticResource enumConverter}, ConverterParameter='IndicadorAcidente', ValidatesOnDataErrors=True, NotifyOnValidationError=True, Mode=TwoWay}"
                            IsEnabled="{Binding Path=IsChecked, ElementName=chkIndicacaoAcidente}"/>
                    </StackPanel>
                </Grid>
            </StackPanel>
        </Grid>
    </StackPanel>
</UserControl>
